﻿//  Created by Mathew Purchase.
//  Copyright (c) 2014 Mathew Purchase. All rights reserved.

using UnityEngine;
using UnityEngine.UI;
using System.Collections;
using System.Collections.Generic;

public class RandomEventService : MonoBehaviour 
{

	//---------------------------------------------------------------------------------------------
	// Properties
	public int randomEventChance;
	
	
	
	//---------------------------------------------------------------------------------------------
	// Members
	public Character m_playerMain;
	public List<EventHolder> m_eventList;
	
	
	
	//---------------------------------------------------------------------------------------------
	// Events and Delegates
	public delegate void RandomEventManager();
	public static event RandomEventManager doEvent;
	
	
	//---------------------------------------------------------------------------------------------
	// Init
	void Start () 
	{
		TurnService.turnEnd += RandomEventTrigger;
		
	}
	//---------------------------------------------------------------------------------------------
	void OnDisable()
	{
		TurnService.turnEnd -= RandomEventTrigger;
	}
	
	//---------------------------------------------------------------------------------------------
	// Core Functions

	void RandomEventTrigger()
	{
	
		if (m_playerMain.inSettlement == false)
		{
			int x = Random.Range(0,100);
			
			if(x  > randomEventChance)
			{
				doEvent();
			}
		}
		
	}
	
	
}
